'use strict';

const Service = require('egg').Service;

class UserService extends Service {
  async find() {
    const datas = await this.ctx.model.User.find();
    return datas;
  }
  // 添加用户
  async add(req) {
    const ctx = this.ctx;
    return ctx.model.User.create(req).then(res => {
      return { success: true, msg: res, code: 0 };
    }).catch(err => {
      return { success: false, err };
    });
  }
}

module.exports = UserService;
